/*
 * @Author: ChenSiTong
 * @Date: 2018-08-24 14:27:17 
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2018-08-24 16:48:33
 */
var main = main || {} ;
main = {
    init:function(){

    },
    staffInfo:{
        init:function(){
            /*
        * 教职工基本信息管理 交互
        * 
        */
            $(".layui-nav-itemed a").hover(function(){
                $(this).css({
                    "color":"#fff"
                })
            },function(){
                $(this).css({
                    "color":"#666"
                })
            })
            //教职工基本信息管理-设置
            $("#staff_bm_setting").on("click",function(){
                console.log(1)
                $(".setting-info-box").removeClass("hide")
                $(".nav-box,.nav-box-2,.c-table").addClass("hide")
            })
            //教职工基本信息管理-查看
            $("#staff_bm_check").on("click",function(){
                console.log(1)
                $(".check-info-box").removeClass("hide")
                $(".nav-box,.nav-box-2,.c-table").addClass("hide")
            })
            //返回
            $("#backToStaffM,#backToStaffM_2").on("click",function(){
                $(".nav-box,.nav-box-2,.c-table").removeClass("hide");
                $(".check-info-box").addClass("hide")
                $(".setting-info-box").addClass("hide")
            })

            //退出弹出
            $(".sign-out-btn").on("click",function(){
                $.get_layer({
                    title: "退出",
                    type:"1",
                    html:$("#close_layer_box").html(),
                    btn_arr:["是","否"],
                    area:['500px', 'auto'],
                    btn1:function(){
                        layer.msg('退出成功',{time:1500},function(){
                            window.location.href = '/login';
                        })
                    },
                    btn2:function(){
                        
                    }
                })
            })
            //修改密码弹窗
            $(".user-setting-btn").on("click",function(){
                $.get_layer({
                    title: "退出",
                    type:"1",
                    html:$("#setting_passwd_box_layer").html(),
                    btn_arr:["确定", "取消"],
                    area:['500px', 'auto'],
                    btn1:function(){
                        var old_pass = $('[name=old_pass]').val();
                        var new_pass = $('[name=new_pass]').val();
                        var re_pass = $('[name=re_pass]').val();
                        var _token = $('[name=_token]').val();
                        if(!old_pass){
                            layer.msg('请输入原密码');
                            return false;
                        }
                        if(!new_pass){
                            layer.msg('请输入新密码');
                            return false;
                        }
                        if(!re_pass){
                            layer.msg('请输入确认密码');
                            return false;
                        }
                        if(re_pass != new_pass){
                            layer.msg('两次输入密码不一致');
                            return false;
                        }

                        $.ajax({
                            url: '/login/changePass',
                            type: 'post',
                            data: {old_pass:old_pass, new_pass:new_pass, re_pass:re_pass, _token:_token},
                            dataType: "json",
                            success: function(re){
                                if(re.code == 1){
                                    layer.msg('密码修改成功',{time:2000},function(){
                                        window.location.reload();
                                    });

                                }else{
                                    layer.msg(re.errMsg);
                                }
                            }
                        })
                    },
                    btn2:function(){

                    }
                })
            })
            }
    },
    myClass:{
        init:function(){
            //增加班级
            $(".class-import").on("click",function(){
                $.get_layer({
                    title: "退出",
                    type:"1",
                    html:$("#class_import_box").html(),
                    btn_arr:["重置","确定"],
                    area:['500px', 'auto'],
                    btn1:function(){
                        
                    },
                    btn2:function(){
                        
                    }
                })
            })
        }
    }

}
